<?php
$total = $this->total;
$file  = Engine_Api::_()->getApi('storage', 'storage');
?>
<?php if ($total):?>
<script type="text/javascript">
$('msg_count').getParent().setStyle('display', '');
$('msg_count').innerHTML = '<?php echo $total;?>';
function makeRead(actionid,href)
{
    window.location = href;
}
</script>
<?php endif;?>
<ul>
<?php if ($total): ?>
<?php foreach ($this->msg as $item):
        $message = $item->getInboxMessage($this->viewer());
        $recipient = $item->getRecipientInfo($this->viewer());
?>
	<?php $subject = Engine_Api::_()->user()->getUser($item->user_id)?>
	<li style="border-top: 1px solid #E0E0E0; <?php if( !$recipient->inbox_read ): echo 'font-weight: bold'; endif; ?>" onclick="makeRead(<?php echo $item->conversation_id;?>,'<?php echo $item->getHref();?>')" >
	<a style="text-decoration: none" onclick="makeRead(<?php echo $item->conversation_id;?>,'<?php echo  $item->getHref();?>')" class="fb_txt" href="javascript:;" style="display: block; overflow: hidden; padding: 0px; white-space: nowrap;">
	<table border="0" width="100%" cellspacing="0" cellpadding="0">
		<tr>
			<td width="18%">
			<?php echo $this->itemPhoto($subject, 'thumb.icon');?>    
			</td>
			<td style="<?php if( !$recipient->inbox_read ): echo 'font-weight: bold'; endif; ?>">
				<a style="text-decoration: none" onclick="makeRead(<?php echo $item->conversation_id;?>,'<?php echo $item->getHref();?>')" href="javascript:;"><?php echo $subject->getTitle()?></a><br />
				<span>
                <?php  ( '' != ($title = trim($message->getTitle())) ||
                  '' != ($title = trim($item->getTitle())));
                $title = html_entity_decode(strip_tags($title));
                echo strlen($title)>50?substr($title,0,50).'...':$title;
                ?>
                </span><br />
				<div class="date"><?php echo $this->timestamp($message->date)?></div>			
				<br />
			</td>
		</tr>
	</table>
	</a>
	</li>
<?php endforeach;?>
<?php else:?>
<div class="no_item_content">
	<span class="none" >
		<?php echo $this->translate('No new messages.')?>
		</span>  
</div>
<?php endif;?>
<li>
<a href="<?php echo $this->url(array('action'=>'inbox'),'messages_general') ?>" class="sfooter">
		<span><?php echo $this->translate('See All Messages')?></span><br />
		<span class="footer_span"><?php echo $total?> <?php echo $this->translate('unread')?></span>
</li>
</a>
</ul>